package com.zqserver.interfaces.user.service;


import com.zqserver.interfaces.user.dao.TZqUserMapper;
import com.zqserver.interfaces.user.model.TZqUser;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by zhouquan on 2017/11/13.
 */
@Service
public class UserService {

    @Resource
    private TZqUserMapper userMapper;

    /**
     * 描述：新增用户
     *
     * @param user
     * @return
     * @author zhouquan
     * @date 2018/3/22 16:10
     */
    public void addUser(TZqUser user) {
        userMapper.insertSelective(user);
    }

    /**
     * 描述：根据id删除用户
     *
     * @param id
     * @return
     * @author zhouquan
     * @date 2018/3/22 16:11
     */
    public void deleteUser(int id) {
        userMapper.deleteByPrimaryKey(id);
    }

    /**
     * 描述：修改用户基本信息
     *
     * @param user
     * @return
     * @author zhouquan
     * @date 2018/3/22 16:11
     */
    public void updateUser(TZqUser user) {
        userMapper.updateByPrimaryKeySelective(user);
    }

    /**
     * 描述：通过id查询用户信息
     *
     * @param id
     * @return
     * @author zhouquan
     * @date 2018/3/22 16:11
     */
    public TZqUser findUserById(int id) {
        return userMapper.selectByPrimaryKey(id);
    }

    /**
     * 描述：分页查询用户信息
     *
     * @author zhouquan
     * @date 2018/3/22 16:12
     */
    public List<TZqUser> listUser(String name) {
        return userMapper.listUserPage(name);
    }
}
